package com.amoby.main.service;

import com.amoby.main.entity.Cbabill;

public enum BillOperation {
    /** 允许转账 */
    allow(1, 3),
    /** 拒绝转账 */
    deny(1, 2),
    /** 转账成功 */
    success(3, 4),
    /** 转账失败 */
    fail(3, 5),
    /** 失败账单手工转账完成 */
    failHandle(5, 4),
    /** 人工处理完成 */
    processed(1, 4);
    private byte frmState;
    private byte toState;

    private BillOperation(int frmState, int toState) {
        this.frmState = (byte) frmState;
        this.toState = (byte) toState;
    }

    public Cbabill flow(Cbabill cbabill) {
        Byte state = cbabill.getState();
        if (this.frmState != state) {
          //  throw new RuntimeException("流转状态错误");
        }
        cbabill.setState(this.toState);
        return cbabill;
    }
}
